--取出拼多多渠道的JT订单
with tmp_order as (
  select
       waybill_id
      ,substr(input_time,1,10) || '-' || substr(input_time,12,2) as input_time
  from jms_dwd.dwd_yl_oms_oms_order_hf    --订单去重记录表（小时表）
  where substr(dt,1,10) = '{{ execution_date | cst_ds }}'
    and waybill_id like 'JT%'
    and order_source_code = 'D09'   --桃花岛订单（拼多多）
    and  waybill_rnk=1
)

insert overwrite table jms_dm.dm_waybillno_max_hi partition (dt)
select
    input_time,
    substr(input_time,1,10) as input_date,
    max(waybill_id)         as waybill_id_max ,
    substr(input_time,1,10) as dt
from tmp_order tmp
where substr(input_time,1,10) = '{{ execution_date | cst_ds }}'
group by input_time,substr(input_time,1,10)
distribute by 1
;